import Sequelize from 'sequelize';
import baseDao from '../lib/baseDao.js'; // 数据库操作

const Modal = baseDao.sequelize.define('t_cashgift', {
  // 属性
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true, // 主键
    autoIncrement: true, // 自增
    allowNull: true,
    validate: {
      len: [1, 50]
    }
  },
  userId: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '创建者Id'
  },
  rightsId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '淘礼金Id'
  },
  tId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '大淘客商品ID'
  },
  goodsId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '淘宝商品ID'
  },
  mainPic: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 200]
    },
    comment: '商品主图'
  },
  dtitle: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '商品短标题'
  },
  rightsUrl: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 500]
    },
    comment: '淘礼金领取Url'
  },
  rightsTkl: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '淘礼金领取淘口令'
  },
  rightsName: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '淘礼金名称(最大10字符)'
  },
  rightsNumber: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '淘礼金总个数'
  },
  rightsPrice: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '单个淘礼金面额，支持两位小数，单位元'
  },
  rightsEndTime: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '使用结束日期，相对：数字，绝对：yyyy-MM-dd'
  },
  rightsEndTimeMode: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '结束日期的模式,1:相对时间，2:绝对时间'
  },
  status: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 5]
    },
    comment: '淘礼金状态：1已创建2已使用3已过期(积分已返还)'
  },
}, {
    // 参数
  });

//向外暴露
export default {
  Modal,
}